home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 1.iso / util / thedit20.zip / words.the < prev    next >
Text File  |  1995-01-26  |  2KB  |  49 lines

  1. /*
  2. $Id: words.the 2.0 1995/01/26 16:32:27 MH Release MH $
  3. */
  4. /***********************************************************************/
  5. /* Description: REXX macro to count the number of words to a target.   */
  6. /* Syntax:      words [target]                                         */
  7. /* Notes:       This macro counts the number of words to the specified */
  8. /*              target.                                                */
  9. /*              Full XEDIT/KEDIT/THE targets are supported.            */
  10. /***********************************************************************/
  11. Trace o
  12. Parse Arg args
  13. If Words(args) = 0 Then args = 1
  14. reply = valid_target(args)
  15. If reply = 'ERROR' Then
  16.    Do
  17.      'EMSG Error: 17 Invalid target' args
  18.      Exit
  19.    End
  20. If reply = 'NOTFOUND' Then
  21.    Do
  22.      'EMSG Error: 17 Target not found' args
  23.      Exit
  24.    End
  25. start_line = Word(reply,1)
  26. nolines = Word(reply,2)
  27. forward = 1                  /* assume direction is forward by defualt */
  28. 'EXTRACT /LINE/SIZE/STAY/'                        /* get various stuff */
  29. current_line = line.1                   /* save current line for later */
  30. If nolines < 0 Then Do                /* if target before current line */
  31.    forward = 0                    /* indicate direction to be backward */
  32.    nolines = nolines * -1                     /* make nolines positive */
  33. End
  34. ':'||start_line
  35. totwords = 0                             /* reset changed line counter */
  36. Do nolines                              /* for each line to target ... */
  37.    'EXTRACT /CURLINE/TOF/EOF'        /* get current line contents, etc.*/
  38.    If tof.1 = 'ON',                    /* ignore line if on TOF or EOF */
  39.    |  eof.1 = 'ON' Then nop
  40.    Else
  41.       totwords = totwords + Words(curline.3)
  42.    If forward = 1 Then 'N'         /* if going forward, get next line */
  43.    Else 'U'                  /* if going backwards, get previous line */
  44.    If rc \= 0 Then Leave                        /* shouldn't get here */
  45. End
  46. 'MSG' totwords 'words counted'
  47. If stay.1 = 'ON' Then ':'||current_line 
  48. Return                                              /* go back to THE */
  49.